﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace GodofTroll
{
    class Controles: Game1
    {
        FundoMovel fundoMovel;
        public KeyboardState currentKeyboard = new KeyboardState();
        public MouseState currentMouse = new MouseState();
        public int kbDelay = 0;

        public void Update(Game1 game1, GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                game1.Exit();

            //carregando a captura de tecla do Keyboard e Mouse
            currentKeyboard = Keyboard.GetState();
            currentMouse = Mouse.GetState();
            kbDelay += gameTime.ElapsedGameTime.Milliseconds;
            IsMouseVisible = true;
            

            if (currentKeyboard.IsKeyDown(Keys.Up))
            {
                game1.personRectangle.Y -= 5;                   
            }
            if (currentKeyboard.IsKeyDown(Keys.Down))
            {
                game1.personRectangle.Y += 5;
            }
            if (currentKeyboard.IsKeyDown(Keys.Right))
            {
                game1.personRectangle.X += 5;
             //   fundoMovel.fundoPosition.X += 1f; 
            }
            if (currentKeyboard.IsKeyDown(Keys.Left))
            {
                game1.personRectangle.X -= 5;
               // fundoMovel.fundoPosition.X -= 1;
            }
            if (currentKeyboard.IsKeyDown(Keys.Space) && game1.pular)
            {
                game1.velocidadeQueda -= game1.velocidadePulo;
                game1.pular = false;
            }

            #region - Switch para pular a Intro.
            switch (game1.telas)
            {
                case GameState.intro1:
                    this.kbDelay += gameTime.ElapsedGameTime.Milliseconds;
                    if (this.currentKeyboard.IsKeyDown(Keys.Escape) && this.kbDelay > 300)
                    {
                        game1.telas = GameState.Menu;
                        this.kbDelay = 0;
                    }
                    break;

                case GameState.intro2:
                    this.kbDelay += gameTime.ElapsedGameTime.Milliseconds;
                    if (this.currentKeyboard.IsKeyDown(Keys.Escape) && this.kbDelay > 300)
                    {
                        game1.telas = GameState.Menu;
                        this.kbDelay = 0;
                    }
                    break;

                case GameState.intro3:
                    this.kbDelay += gameTime.ElapsedGameTime.Milliseconds;
                    if (this.currentKeyboard.IsKeyDown(Keys.Escape) && this.kbDelay > 300)
                    {
                        game1.telas = GameState.Menu;
                        this.kbDelay = 0;
                    }
                    break;

                case GameState.intro4:
                    this.kbDelay += gameTime.ElapsedGameTime.Milliseconds;
                    if (this.currentKeyboard.IsKeyDown(Keys.Escape) && this.kbDelay > 300)
                    {
                        game1.telas = GameState.Menu;
                        this.kbDelay = 0;
                    }
                    break;

                case GameState.intro5:
                    this.kbDelay += gameTime.ElapsedGameTime.Milliseconds;
                    if (this.currentKeyboard.IsKeyDown(Keys.Escape) && this.kbDelay > 300)
                    {
                        game1.telas = GameState.Menu;
                        this.kbDelay = 0;
                    }
                    break;
            #endregion

            }
        }
    }
}
